package com.ecgsystem.activity;

import java.util.ArrayList;
import java.util.HashMap;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

import com.ecgsystem.constants.Constants;
import com.ecgsystem.panel.LazyAdapter;

/**
 * TODO Put here a description of what this class does.
 * 
 * @author ANHTUAN. Created Sep 28, 2012.
 */
public class PatientList extends Activity implements Constants {
	private ListView patientListView;

	private LazyAdapter adapter;
	public static ArrayList<HashMap<String, String>> patientListArr;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.patient_list);

		patientListArr = MainActivity.conn
				.getPatientList();

		this.patientListView = (ListView) findViewById(R.id.listView_patient_list);
		adapter = new LazyAdapter(this, patientListArr);
		
		this.patientListView.setAdapter(adapter);

		this.patientListView.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> arg0, View arg1,
					int position, long id) {
				Bundle tab = new Bundle();
				tab.putInt(
						"clickedposition",
						position);

				Intent i = new Intent(PatientList.this, PatientTab.class);
				i.putExtras(tab);
				startActivity(i);
				finish();
			}
		});

		/*final EditText filterEd = (EditText) findViewById(R.id.filterPatient);
		filterEd.setOnKeyListener(new OnKeyListener() {

			public boolean onKey(View v, int keyCode, KeyEvent event) {
				PatientList.this.enteredStr = filterEd.getText().toString();
				adapter.getFilter().filter(PatientList.this.enteredStr);
				return false;
			}
		});*/
	}
}
